﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EAGL.Core
{
    public static class Randomizer
    {
        private static Random rand;

        public static void init()
        {
            if (rand == null)
                rand = new Random();
        }

        public static int GetRandomFromEnum(Type type)
        {
            if (type.IsEnum)
            {
                init();
                Array vals = Enum.GetValues(type);
                int c = vals.Length;
                int x = rand.Next(c);
                return x;
            }
            else
            {
                throw new Exception("Not and enum");
            }
        }
    }
}
